Skip to main content

API Setup

Status Codes

CodeDescription
200Success
401Unauthorized (missing token)
403Forbidden (invalid token)
500Server error

Available Endpoints

  • POST https://api-qa.brillar.ai/api/post-login/user-login - Authenticate users
  • POST https://api-qa.brillar.ai/api/post-login/new-transaction - Create a new transaction
  • POST https://api-qa.brillar.ai/api/post-login/user-logout - Log users out

Setup For Javascript

1. Install Required Package

npm install axios

2. Authentication

All API requests require a token in the Authorization header:

headers: {
Authorization: `${token}`
}

API Implementation

1. User Login

import axios from 'axios';

const SERVER_URL = 'https://api-qa.brillar.ai';

async function loginUser(credentials) {
try {
const response = await axios.post(`${SERVER_URL}/api/post-login/user-login`,
{
userId: credentials.userId,
data:{
"employeeId":"4243234"
}
},
{
headers: { Authorization: `${token}` }
}
);
return true;
} catch (error) {
console.error('Login failed:', error.response?.data || error.message);
throw error;
}
}

2. Create Transaction

async function createTransaction(credentials,transactionData, token) {
try {
const response = await axios.post(
`${SERVER_URL}/api/post-login/new-transaction`,
{
userId: credentials.userId,
agentId: credentials.agentId,
transaction: transactionData
},
{
headers: { Authorization: `Bearer ${token}` }
}
);
return true;
} catch (error) {
console.error('Transaction failed:', error.response?.data || error.message);
throw error;
}
}

3. User Logout

async function logoutUser(userData, token) {
try {
await axios.post(
`${SERVER_URL}/api/post-login/user-logout`,
{
userId: userData.userId,
agentId: userData.agentId
},
{
headers: { Authorization: `${token}` }
}
);

return true;
} catch (error) {
console.error('Logout failed:', error.response?.data || error.message);
throw error;
}
}